<?php
include('../../../config.php');
include(PUNG_ROOT . '/admin/header.php');

$adminmenu = array(
CONTENT_001 => 'index.php',
CONTENT_002 => 'new.php'
);

if($_GET['delete'])
{
	$id = $_GET['delete'];
	$db -> db_query("DELETE FROM " . DB_PREFIX . "content WHERE id = '$id'");
	
	redirect_with_message('msg', 'CONTENT_011');
}

if(isset($_POST['submit']))
{
	$db -> db_query("UPDATE " . DB_PREFIX . "content SET front = 'no'");
	$db -> db_query("UPDATE " . DB_PREFIX . "content SET front = 'yes' 
	WHERE id = '" . $_POST['frontpage'] . "'");
	
	redirect_with_message('msg', 'CONTENT_012');
}

include(PUNG_ROOT . '/admin/head.php');

$sql = $db -> db_query("SELECT * FROM " . DB_PREFIX . "content ORDER BY id DESC");
$sql = $db -> db_result();
?>

<h3><?php print CONTENT_003; ?></h3>

<form action="" method="post">
<table width="100%">
<tr>
	<th width="30"><?php print CONTENT_006; ?></th>
	<th><?php print CONTENT_004; ?></th>
	<th width="60">&nbsp;</th>
</tr>
<?php foreach($sql as $page) { ?>
<tr>
	<td align="center">
	<?php
	print '<input type="radio" name="frontpage" value="' . $page['id'] . '"';
	if($page['front'] == 'yes')
	{
		print ' checked="checked"';
	}
	print ' />';
	?>
	</td>
	<td><?php print stripslashes($page['title']); ?></td>
	<td align="center">
	<a href="edit.php?id=<?php print $page['id']; ?>" title="<?php print CONTENT_010; ?>"><img 
	src="<?php print PUNG_URL . '/images/admin_img/edit.png'; ?>" alt="<?php print CONTENT_010; ?>" /></a>
	
	<a href="#" onclick="confirm_box('<?php print CONTENT_009; ?>', '?delete=<?php print $page['id']; ?>');" 
	title="<?php print CONTENT_008; ?>"><img src="<?php print PUNG_URL; ?>/images/admin_img/uninstall.png" alt="<?php print CONTENT_008; ?>" /></a>
	</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" class="form_button" value="<?php print CONTENT_007; ?>" name="submit" />
</form>

<?php
include(PUNG_ROOT . '/admin/footer.php');
?>